Fix silent dropping of stints in legacy list format (#863)#872
Open
gabrielrv13 wants to merge 1 commit intotheOehrly:mainfrom
Open
Fix silent dropping of stints in legacy list format (#863)#872gabrielrv13 wants to merge 1 commit intotheOehrly:mainfrom
gabrielrv13 wants to merge 1 commit intotheOehrly:mainfrom
Conversation
Historic races (approx. 2018-2019) return Stints from the timing app API as a plain list instead of a dict with string indices. The previous parser assumed dict format unconditionally, causing all stints to be silently dropped when a list was received. Normalize list format to dict before iteration, and switch the loop to use .items() directly, removing the ambiguous isinstance check that was previously inside the loop body. Fixes theOehrly#863
Owner
|
@gabrielrv13 thanks for the PR, we will try to take a look at is soon :) @Casper-Guo do you want to review (if you have time), since you have looked into this issue in more depth already? I only have a superficial grasp of the problem at this point. |
Contributor
|
Gladly. This code is some of the oldest in the project and the flow is hard to follow. Haven't really worked with the API module before so I will need to look at the raw data more before I can assess the correctness of the fix as well. Just need to find a bigger chunk of time, hopefully over the next week |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Historic races (approx. 2018–2019) return
Stintsfrom the timing app API as a plain list instead of a dict with string indices. The previous parser assumed dict format unconditionally, causing all stints to be silently dropped when a list was received, no error, no warning.Fixes #863, related to #860.
Root cause
In
timing_app_data(fastf1/_api.py), the loop over stints usedenumerate(update)and only reassignedstint_numberandstintinside anisinstance(update, dict)check. Whenupdatewas a list, the check was never entered, but the list itself was never normalized, causing downstream code to receive incomplete data.Fix
Normalize the list format to dict before the loop:
This removes the ambiguous
isinstancecheck inside the loop body and makes the two formats converge before any processing happens.Validation
Tested against:
Tests
Two unit tests added to
fastf1/tests/test_api.py:test_timing_app_data_legacy_list_format: verifies list format is parsed correctly and no stints are droppedtest_timing_app_data_modern_dict_format: verifies dict format continues to work as before